/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tos.tasprep;

/**
 *
 * @author Milos
 */

/* Klasa koja sadrzi promenljive za kontrolu*/
public class Variables 
{
    // Promenljiva koja prikazuje koji proces je na redu
    private int noOfProcesses;
    private boolean [] wait;
    private boolean forbiden;

    // Konstruktor
    public Variables(int noOfProcesses)
    {
        this.noOfProcesses = noOfProcesses;
        wait = new boolean [noOfProcesses];
       
        for (int i = 0; i < noOfProcesses; i++)
        {
            wait [i] = false;
        }

        forbiden = false;
    }

    public synchronized boolean TAS (boolean forbiden)
    {
        boolean start = forbiden;
        setForbiden (true);
        return start;
    }

    public int getNoOfProcesses() {
        return noOfProcesses;
    }

    public void setNoOfProcesses(int noOfProcesses) {
        this.noOfProcesses = noOfProcesses;
    }

    public void setWait (int index, boolean want)
    {
        wait [index] = want;
    }

    public boolean getWait (int index)
    {
        return wait [index];
    }

    public boolean[] getWait() {
        return wait;
    }

    public void setWait(boolean[] wait) {
        this.wait = wait;
    }

    public boolean isForbiden() {
        return forbiden;
    }

    public void setForbiden(boolean forbiden) {
        this.forbiden = forbiden;
    }
}
